<?php

namespace app\mall\ui\table;

use app\mall\enum\FreightEnum;
use app\mall\enum\StatusEnum;
use app\mall\enum\StockTypeEnum;
use app\mall\model\MallCate;
use suframe\thinkAdmin\ui\table\TableInterface;

/**
 * 公共商品表格
 */
class MallGoodsTable extends TableInterface
{
    public function header()
    {
        return [
            'id' => ['label' => 'ID', 'sort' => true, 'fixed' => 'left', 'width' => 70],
            'image'=> ['label' => '封面图片', 'type' => 'image', 'width' => 77],
            'title'=> ['label' => '商品名称'],
            'cate_name'=> ['label' => '分类', 'width' => 120],
            'price'=> ['label' => '价格', 'sort' => true, 'width' => 73],
            'sale_volume'=> ['label' => '销量', 'sort' => true, 'width' => 73],
            'praise_volume'=> ['label' => '好评数', 'sort' => true, 'width' => 88],
            'freight_type_text'=> ['label' => '发货方式', 'filter' => FreightEnum::toZhArray(), 'width' => 90, 'field' => 'freight_type'],
            'status_text'=> ['label' => '状态', 'width' => 70, 'field' => 'status', 'filter' => StatusEnum::toZhArray()],
            'create_date'=> ['label' => '创建时间', 'width' => 100],
            'more' => [
                'label' => '更多设置',
                'type' => 'link',
                'width' => 90,
                'linkConfig'  => [
                    [
                        'key' => 'id', 'label' => '更多设置', 'icon' => 'el-icon-more',
                        'url' => '/mall/admin/mallGoodsSetting/index', 'vars' =>['id'], 'type' => 'link',
                        'blank' => true, 'blankName' => '商品设置'
                    ],
                ]
            ],
        ];
    }

    public function filters()
    {
        return [
            'title' => ['label' => '商品名称', 'type' => 'text'],
            'search_cate_ids' => ['label' => '分类', 'type' => 'cascader', 'value' => MallCate::getTree(), 'checkStrictly' => true],
        ];
    }
}